home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.20021006-20030409
/
000335_fdc@columbia.edu_Sun Feb 23 14:55:54 EST 2003.msg
< prev
next >
Wrap
Text File
|
2003-04-08
|
5KB
|
104 lines
Article: 14132 of comp.protocols.kermit.misc
Path: newsmaster.cc.columbia.edu!news.columbia.edu!news-not-for-mail
From: fdc@columbia.edu (Frank da Cruz)
Newsgroups: comp.os.linux.misc,comp.protocols.kermit.misc
Subject: Re: ls in ftp client, help needed
Date: 23 Feb 2003 13:07:25 -0500
Organization: Columbia University
Lines: 87
Message-ID: <b3b2kt$h01$1@watsol.cc.columbia.edu>
References: <3e57ce85$1@spamkiller.newsgroups.com>
NNTP-Posting-Host: watsol.cc.columbia.edu
X-Trace: newsmaster.cc.columbia.edu 1046023646 16826 128.59.39.139 (23 Feb 2003 18:07:26 GMT)
X-Complaints-To: postmaster@columbia.edu
NNTP-Posting-Date: 23 Feb 2003 18:07:26 GMT
Xref: newsmaster.cc.columbia.edu comp.os.linux.misc:583862 comp.protocols.kermit.misc:14132
In article <3e57ce85$1@spamkiller.newsgroups.com>,
Fredrik Lindstr�m <95710594@noone.com> wrote:
: How do I display information about the creation year of a file when using
: the ls (LIST) command?
:
: LIST -aL shows everything I need except seconds and year.
:
: --full-time does not work when invoked with LIST command.
:
As others have pointed out, Unix-based FTP servers just run the external
ls command with its fractured date-time format. Sometimes you can pass
options to the remote ls program, but only ones that it happens to
understand (thus, as another poster pointed out, it will not understand
"--full-time" if it's not GNU ls). But there's a larger problem, namely
that remote file timestamps are shown in the server's local time, but
the client has no way of knowing what timezone the server is in.
One way to do what you want is to use the Kermit FTP client:
http://www.columbia.edu/kermit/ftpclient.html
and write a script to get the file list and then get the modtime of each
file using the FTP MDTM directive (which most servers support). Here's
an example:
set quiet on ; No messages
set exit warning off ; No warnings
.listname := /tmp/list.\v(pid) ; Temp file name
ftp open kermit.columbia.edu /anonymous ; Open FTP connection
if fail exit 1 ; Check
cd kermit/g ; CD to disired directory
if fail exit 1 ; Check
mget /namelist:\m(listname) * ; Get list of names into file
if fail exit 1 ; Check
fopen /read \%c \m(listname) ; Open name-list file
if fail exit 1 ; Check
while true { ; Loop to read each line
fread /line \%c name ; Read a name
if fail break ; Check for EOF
ftp quote MDTM \m(name) ; Get file's modtime
if fail exit 1 "Server does not support MDTM" ; Check
.time := \v(ftp_message) ; Save
ftp size \m(name) ; Get file's size
if fail exit 1 "Server does not support SIZE" ; Check
.size := \v(ftp_message) ; Save
echo "\flpad(\m(size),12) \fcvtdate(\m(time)) \m(name)" ; Show info
}
fclose \%c ; Close name-list file
delete \m(listname) ; Delete name-list file
exit ; BYE to server and exit Kermit
The result looks like this:
9018 20020319 23:53:17 ANNOUNCE
17989 19991227 22:01:15 COPYING
45127 19991227 22:01:15 README
4324 20020318 15:26:51 README.68K
40521 20021030 21:07:37 aavnew.hlp
18331 20020318 15:27:23 cpm68k.diff
10202 19991227 22:01:15 gcmdline.c
34888 19991227 22:01:15 gkermit.c
7189 19991227 22:01:15 gkermit.h
14106 19991227 22:01:15 gkermit.nr
11743 19991227 22:01:15 gproto.c
6426 19991227 22:01:15 gproto.w
29269 19991227 22:01:15 gunixio.c
30658 20010701 16:30:58 gunixio_os2.c
14902 19991227 22:01:15 gwart.c
3220 19991227 22:01:15 makefile
The times shown are UTC (GMT). As you can see, the size, date, and name
are available programmatically, so you can make decisions based on them,
display them in different formats, etc.
For a Kermit tutorial see:
http://www.columbia.edu/kermit/ckututor.html
For a Kermit script-writing tutorial, see:
http://www.columbia.edu/kermit/ckscripts.html
For a tutorial on FTP scripting, see:
http://www.columbia.edu/kermit/ftpscripts.html
- Frank